#include<stdio.h>
#include<signal.h>
#include<unistd.h>
#include<string.h>

struct sigaction act,oact;

void handler(int signo)
{
    printf("get a signal :%d\n",signo);
    //恢复block位图
    sigaction(2,&oact,&act);
}
int main()
{
    //初始化
    memset(&act,0,sizeof(struct sigaction));
    memset(&oact,0,sizeof(struct sigaction));
    //设置block位图
    act.sa_handler=handler;
    sigaddset(&act.sa_mask,4);
    sigaction(2,&act,&oact);
    while(1)
    {
        printf("I an running...\n");
        sleep(1);
    }
    return 0;
}
